package com.youan.pangu.security.listener;

import com.youan.pangu.base.bean.GlobalValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @description:
 * @author: 辛晟昊
 * @time: 2020/3/9 10:15
 */
public class SecurityCheckAppStartedListener implements ApplicationListener<ApplicationStartedEvent> {

    @Autowired(required = false)
    private UserDetailsService userDetailsService;

    private Logger logger = LoggerFactory.getLogger(GlobalValue.LOOGER_NAME);

    @Override
    public void onApplicationEvent(ApplicationStartedEvent event) {
        logger.info("检查Security运行参数 === 开始");
        if(null == userDetailsService){
            logger.error("系统中未设置<UserDetailsService>实现类，系统无法按预期运行");
        }
        logger.info("检查Security运行参数 === 结束");
    }
}
